package com.neo.springboot.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import com.neo.springboot.damain.User;

public interface UserRepository extends JpaRepository<User, Long>{

	User findByUsername(String username);
	
	List<User> findByUsernameOrEmail(String username, String email);
	
	long countByUsername(String username);
	
	User findByUsernameIgnoreCase(String username);
	
	List<User>findByEmailLike(String email);
	
	@Transactional(timeout = 10)
	@Modifying
	@Query(value = "update UserInfo u set u.username = ?1 where u.id = ?2", nativeQuery = true)
	int modifyByIdAndUsername(String username, Long id);
}
